package me.aiyou.aiyounews;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import org.apache.cordova.*;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.umeng.analytics.MobclickAgent;

public class AiYouMainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_ai_you_main);
        //super.loadUrl("file:///android_asset/www/index.html");
        super.loadUrl("http://www.aiyou.me");
        //super.loadUrl("http://demos.kendoui.com/mobile/application/index.html");
        //super.loadUrl("http://eval.coseinc.com/pgap/index.html");
        //super.loadUrl("http://www.syscan.org/wp");
        
        WebSettings ws = super.appView.getSettings();
        ws.setSupportZoom(true);
        //ws.setBuiltInZoomControls(true);

    }
    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
        super.loadUrl("javascript:window.location.reload();"); 
        // Normal case behavior follows
    }
    
    @Override
    protected void onPause() {
    	super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_ai_you_main, menu);
        return true;
    }
  //handle menu item selection
    public boolean onOptionsItemSelected(MenuItem item)
    {
		switch (item.getItemId()) {
		case R.id.menu_id_share:
			//startActivity(new Intent(this, Prefs.class));
			ShareApp();
			return true;
		case R.id.menu_id_signout:
			finish();
			return true;
		case R.id.menu_id_refresh:
			super.loadUrl("javascript:window.location.reload();");
			return true;
		case R.id.menu_id_about:
			Intent intent = new Intent(this, AboutActivity.class);
			this.startActivity(intent);
			return true;
		}
		return false;
    }
	private void ShareApp()
	{
		Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
		shareIntent.setType("text/plain");
		shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "hi，大家快来围观爱游观察吧");
		shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "爱游观察|专注于旅游领域的科技博客-http://www.aiyou.me");

		startActivity(Intent.createChooser(shareIntent, "爱游观察"));
	}
}
